<?php
/**
 * The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */

get_header(); ?>

		<div id="container">
			<div id="content" role="main">
			<div class="inner-content">
				<ul id="tips-flow">
					<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
					<li>
						<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
						
							<?php
							// AnLTH - Start init the content variables
							// Use it to display on page.
							
							$the_title = get_the_title();
							$the_content = get_the_content();
							$the_tags = get_the_tags();
							
							if(($the_tags) > 0) {
								$the_tag = array_shift(array_values($the_tags));
								$the_tag = $the_tag->name;
							} else if((get_the_category()) > 0){
								$the_cats = get_the_category();
								$the_cat = array_shift(array_values($the_cats));
								
								$the_tag = $the_cat->name;
							} else $the_tag = 'Other';
							$tip_link = get_post_permalink();
							
							$large_image_url = get_bloginfo('stylesheet_directory')."/images/home-default-image.png";
							if ( has_post_thumbnail()) {
								$large_image_urls = wp_get_attachment_image_src( get_post_thumbnail_id(), 'home-thumb');
								$large_image_url = $large_image_urls[0];
							}
													
							// Sample
							
							//echo $the_content;
							//echo $the_tag;
							//echo "<img src='".$large_image_url."' />";
							//echo "<a href='".$tip_link."' />URL</a>";
							//print_r($post);
							?>
							<a href="<?php echo $tip_link; ?>" alt="<?php the_title(); ?>" >
								<img class="wp-post-image" src="<?php echo $large_image_url; ?>" alt="<?php echo $the_title; ?>"/>
							</a>
							<h1><?php echo $the_title; ?></h1>

							
						</div><!-- #post-## -->
						<div class="ribbon-wrapper-green"><div class="ribbon-green"><?php echo substr($the_tag, 0 , 10);  ?></div></div>
						<!--
						<div class="tag-mask"><span class="rotate_45"><?php echo substr($the_tag, 0 , 10);  ?></span></div>
						-->
						<a class="read-more-btn" href="<?php echo $tip_link; ?> ">
							<img src="<?php bloginfo('stylesheet_directory') ?>/images/plus-btn.gif" alt="Read more ..."/>
						</a>
					</li>
					<?php endwhile; // end of the loop. ?>
				</ul>
				<span id="btnPrev"><a alt="#" href="#">&nbsp;</a></span>
				<span id="btnNext"><a alt="#" href="#">&nbsp;</a></span>
			</div>
			</div><!-- #content -->
		</div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>
